<?php

namespace App\Http\Requests\Api;

class CoachOrdersRequest extends FormRequest
{

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        switch ($this->method()) {
            case 'GET':
            {
                return [
                    'id' => ['required', 'exists:shop_user,id'],
                ];
            }
            case 'POST':
            {
                return [
                    'code' => ['required'],
                    'coach_id' => ['required', 'exists:coaches,id'],
                    'select_num' => ['required', 'integer'],
                    'username' => ['required', 'string'],
                    'phone' => ['required', 'phone:CN,mobile'],
                ];
            }
            default:
            {
                return [

                ];
            }
        }
    }

    public function messages()
    {
        return [
            'code.required'=>'code不能为空',
            'coach_id.required'=>'私教ID不能为空',
            'coach_id.exists'=>'私教ID不存在',
            'select_num.required'=>'所选节数不能为空',
            'select_num.integer'=>'所选节数只能是数字',
            'username.required'=>'姓名不能为空',
            'username.string'=>'姓名只能是字符',
            'phone.required'=>'手机号码不能为空',
            'phone.phone'=>'手机号码填写有误',
        ];
    }
}
